package Gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.text.NumberFormat;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class RandomizePointsDialog extends JDialog
{
	private static final long serialVersionUID = -8899849592710263503L;
	
	private JFormattedTextField numberField;
	private MainWindow mainWindow;
	 public RandomizePointsDialog(MainWindow mWindow)
	 {
		 super(mWindow, true);
		 mainWindow = mWindow;
		 final JDialog dialog = this;
		 JPanel inputPanel = new JPanel();
		 inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.X_AXIS));
		 inputPanel.add(new JLabel("Anzahl Punkte:"));
		 inputPanel.add(Box.createRigidArea(new Dimension(10, 10)));
		 numberField = new JFormattedTextField(NumberFormat.getNumberInstance());
		 numberField.setValue(new Long(100));
		 inputPanel.add(numberField);
		 inputPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		 getContentPane().add(inputPanel, BorderLayout.NORTH);
		 getContentPane().add(new JButton(new AbstractAction("OK")
			{
				private static final long serialVersionUID = 9140613519878493935L;

				public void actionPerformed(ActionEvent e)
				{
					long numPoints = (Long)numberField.getValue();
					mainWindow.randomizePoints((int)numPoints);
					dialog.setVisible(false);
				}
			}), BorderLayout.SOUTH);
	
		 setSize(200, 100);
		 setLocationRelativeTo(mWindow);

	 }
}
